.TH std::ranges::slide_view::slide_view 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::ranges::slide_view::slide_view \- std::ranges::slide_view::slide_view

.SH Synopsis
   constexpr explicit slide_view( V base, ranges::range_difference_t<V>   (since C++23)
   n );

   Constructs a slide_view initializing the underlying data members:

     * move construct the underlying view base_ with std::move(base),
     * the "window size" n_ with n.

.SH Parameters

   base - the source view
   n    - the "sliding window" size

.SH Example


// Run this code

 #include <algorithm>
 #include <iostream>
 #include <ranges>

 int main()
 {
     const auto source = {1, 2, 3, 4};

     auto slide = std::views::slide(source, 3);

     std::ranges::for_each(slide, [](std::ranges::viewable_range auto&& w)
     {
         std::cout << '[' << w[0] << ' ' << w[1] << ' ' << w[2] << "]\\n";
     });
 }

.SH Output:

 [1 2 3]
 [2 3 4]
